package com.yilin.tms.gps.controller;


import com.yilin.tms.core.application.ReturnData;
import com.yilin.tms.core.commons.base.BaseController;
import com.yilin.tms.core.commons.annotation.Explain;
import com.yilin.tms.core.commons.annotation.NotNull;
import com.yilin.tms.core.entity.gps.GpsPoint;
import com.yilin.tms.gps.service.ITrailStorageService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author 专查mongo数据库数据
 */
@RestController
@RequestMapping("/gps/mongo/")
public class GpsMongoController extends BaseController {

    @Resource
    ITrailStorageService trailStorageService;


    /**
     * 实时查询运单轨迹 推荐(查mongo
     */
    @PostMapping("getLocusByMongo")
    @NotNull("tid")
    public ReturnData<List<GpsPoint>> getLocusByMongo(@Explain("轨迹ID") String tid, String gpsTime, Integer page, Integer limit) {
        List<GpsPoint> track;
        if (gpsTime != null) {
            track = trailStorageService.findAllPointsByDate(tid, gpsTime);
        } else {
            track = trailStorageService.findAllPointsByTraceId(tid, page, limit);
        }
        return jsonView(true, "获取成功", track);
    }
}
